home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MISC.SWG / 0033_True EXE Size.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  1KB  |  51 lines

  1. {
  2. STEVE ROGERS
  3.  
  4. > Also, does anyone know how PKware wrote the ZIP2EXE Program? I'm also
  5. >writing an encryption Program, and I thought a 'self-decrypting' File
  6. >would be neat, so I had some ideas on how to do it. Could you just
  7. >append the encrypted data to the end of a short 'stub' Program, which
  8. >just seeks in how ever many Bytes and  reads from there? Or would I
  9. >have to somehow assign all the data to a few Typed Constants?
  10.  
  11. Just so happens I have been dealing With the same problem. I have
  12. written a Procedure to show the "True" size of an EXE File. Knowing this
  13. you can easily get to your "data area" by seeking past the "True" size.
  14.  
  15. ( Acknowledgements to Andy McFarland and Ray Duncan )
  16. }
  17.  
  18. Function exesize(fname : String) : LongInt;
  19. Type
  20.   t_size = Record
  21.     mz : Array [1..2] of Char;
  22.     remainder,
  23.     pages : Word;
  24.   end;
  25.  
  26. Var
  27.   f  : File of t_size;
  28.   sz : t_size;
  29.  
  30. begin
  31.   assign(f,fname);
  32.   {$i-}
  33.   reset(f);
  34.   {$i+}   { io checking should be off }
  35.   if (ioresult <> 0) then
  36.     exesize:= 0
  37.   else
  38.   begin
  39.     read(f,sz);
  40.     close(f);
  41.     With sz do
  42.       exesize := remainder + (pred(pages) * 512);
  43.   end;
  44. end;
  45.  
  46.  
  47. {
  48. This thing reads the header of an EXE File and gets the info there. I
  49. was amazed when I ran this on a bunch of progs and found how many have
  50. data appended. Hope it helps. :)
  51. }